package chat;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

import usuario.Usuario;

import controle.Contato;
import controle.SocketControlConstants;

public class ClientWorker extends Thread implements SocketControlConstants{
	
	private Contato contato;
	private String text;
	private int portaSaida;
	
	public ClientWorker(Contato contato, String text, int i)
	{
		this.contato = contato;
		this.text = text;
		this.portaSaida = i;
	}
	
	public void run()
	{
		Socket socket;
		
		try 
		{
			socket = new Socket(this.contato.getIp(), this.portaSaida);
			ObjectOutputStream oo = new ObjectOutputStream(socket.getOutputStream());
			oo.writeObject(text);
	        socket.close();   
		} 
		catch (UnknownHostException e) 
		{
			e.printStackTrace();
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
		
	}


}
